package psn.hui.sys.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import psn.hui.sys.domain.LogInfo;
import psn.hui.sys.mapper.LogInfoMapper;
import psn.hui.sys.service.LogInfoService;
import psn.hui.sys.utils.DataGridView;
import psn.hui.sys.vo.LogInfoVo;

/**
 * 	登录日志信息服务
 * @author hui
 *
 */
@Service
public class LogInfoServiceImpl implements LogInfoService {
	
	@Autowired
	private LogInfoMapper logInfoMapper;
	/**
	 * 条件查询登录日志
	 */
	@Override
	public DataGridView queryAllLogInfo(LogInfoVo logInfoVo) {
		Page<Object> page = PageHelper.startPage(logInfoVo.getPage(), logInfoVo.getLimit());
		List<LogInfo> logInfos = logInfoMapper.queryAllLogInfo(logInfoVo);
		return new DataGridView(page.getTotal(), logInfos);
	}
	/**
	 * 	根据id删除登录日志
	 */
	@Override
	public int deleteById(Integer id) {
		return logInfoMapper.deleteByPrimaryKey(id);
	}
	/**
	 * 批量根据id删除登录日志
	 */
	@Override
	public int batchDeleteLogInfoByIds(Integer[] ids) {
		int rs = 0;
		for (Integer id : ids) {
			rs += logInfoMapper.deleteByPrimaryKey(id);
		}
		return rs;
	}
	/**
	 * 	添加登录日志
	 * @param logInfo
	 * @return
	 */
	public int addLogInfo(LogInfo logInfo) {
		return logInfoMapper.insertSelective(logInfo);
	}
}
